package com.hzdl.library.dao.impl;

import com.hzdl.library.dao.AddReaderDao;
import com.hzdl.library.domain.ReaderInfo;
import com.hzdl.library.util.JDBCUtils;
import org.junit.Test;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.Date;

/**
 * author : jm
 */
public class AddReaderDaoImpl implements AddReaderDao {
    JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public void addOneReader(ReaderInfo readerInfo) {
        String sql = "insert into reader_info values(?,?,?,?,?,?)";
        template.update(sql,readerInfo.getReader_id(),readerInfo.getName(),readerInfo.getSex(),
                readerInfo.getBirth(),readerInfo.getAddress(),readerInfo.getTelcode());
    }

    @Test
    public void mm(){
        ReaderInfo readerInfo = new ReaderInfo(1,"sbq","女",new Date(),"shanghai","12");

        addOneReader(readerInfo);
    }
}
